package om.myjava.Linkedlist;

import java.util.ArrayList;

class Person{
    String name;
    Person(String name){
        this.name=name;
    }
}

public class ArraylistDemo2 {
   
    public static void main(String[] args) {
        //学生 
        Person p1 = new Person("xiaoming");
        Person p2 = new Person("xiaohua");
        Person p3 = new Person("xiaohu");
        ArrayList<Person> c1 = new ArrayList<>();
        c1.add(p1);
        c1.add(p2);
        c1.add(p3);

        Person p4 = new Person("huhua");
        Person p5 = new Person("huhu");
        //班级
        ArrayList<Person> c2 = new ArrayList<>();
        c2.add(p4);
        c2.add(p5);
        
        
        ArrayList<ArrayList<Person>> n1 = new ArrayList<>();
        n1.add(c1);
        n1.add(c2);
        for (ArrayList<Person>c:n1) {
            for (Person p:c) {
                System.out.println(p.name);
            }

        }

    }
}
